/*
	Simple Software Renderer (SSRenderer)
	Copyright (C) 2007 Piotr Orzechowski <piotr.orzechowski@gmail.com>

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef _SSR_H
#define _SSR_H

#include "./SSRTypes.h"
#include "./ISSRObject.h"
#include "./SSRSurface.h"
#include "./ISSRDevice.h"
#include "./SSRRenderTarget.h"
#include "./SSRRenderer.h"

namespace ssr
{

/**
	Template function which creates an instance of the display device.
	Each device implementation has to declare friendship with this function.

	Important: createDevice() is the only way of creating an instace of ISSRDevice.

	When the object is no longer needed, just call SSR_RELEASE(ptr)
	with a pointer to the object.

	@param pDevice reference to a pointer to store newly created device
	@param width width of the device window
	@param height height of the device window
	@param pTitle NULL-ended string containing title of the window

	@return result integer code, 0 if successful
*/

template<class T> s32 createDevice(ISSRDevice* &pDevice, u32 width, u32 height, const char *pTitle)
{
	pDevice = new T();
	if (pDevice != NULL)
	{
		return pDevice->_CreateDevice(width, height, pTitle);
	}

	return -1;
}

} // namespace

#endif
